package cn.sumpu.app.guoguojie.biz.impl;

import cn.sumpu.app.guoguojie.biz.AppActivityRegisterBiz;
import cn.sumpu.app.guoguojie.dao.AppActivityDao;
import cn.sumpu.app.guoguojie.dao.AppActivityRegisterDao;
import cn.sumpu.app.guoguojie.domain.AppActivity;
import cn.sumpu.app.guoguojie.domain.AppActivityRegister;
import cn.sumpu.app.guoguojie.exception.AppBusinessException;

public class AppActivityRegisterBizImpl implements AppActivityRegisterBiz {
	private AppActivityRegisterDao appActivityRegisterDao;
	private AppActivityDao appActivityDao;
	
	public void setAppActivityDao(AppActivityDao appActivityDao) {
		this.appActivityDao = appActivityDao;
	}
	public void setAppActivityRegisterDao(
			AppActivityRegisterDao appActivityRegisterDao) {
		this.appActivityRegisterDao = appActivityRegisterDao;
	}
	@Override
	public void insert(AppActivityRegister appActivityRegister)
			throws AppBusinessException {
		if(appActivityRegister.getBaby()==null){
			appActivityRegister.setBaby(0);
		}
		appActivityRegisterDao.insert(appActivityRegister);
		AppActivity appActivity=new AppActivity();
		appActivity.setIdentifier(appActivityRegister.getActivity());
		appActivity.setRegistered(appActivityRegister.getGrownUp()+appActivityRegister.getBaby());
		appActivityDao.update(appActivity);
		
		
	}
	@Override
	public void update(AppActivityRegister appActivityRegister)
			throws AppBusinessException {
		appActivityRegisterDao.update(appActivityRegister);

	}

	@Override
	public AppActivity getAppActivityRegisterById(String identifier)
			throws AppBusinessException {
		return appActivityRegisterDao.getAppActivityRegisterById(identifier);
	}

	@Override
	public void deleteById(String identifier) throws AppBusinessException {
		appActivityRegisterDao.deleteById(identifier);

	}

	

}
